package com.ztom.daily.n2022.m5;

/**
 * 删除造序
 * <p>
 * https://leetcode.cn/problems/delete-columns-to-make-sorted/
 *
 * @author ZhangTao
 */
public class Day12MinDeletionSize {

    public int minDeletionSize(String[] strs) {
        if (strs == null || strs.length == 0) {
            return -1;
        }

        int m = strs.length;
        int n = strs[0].length();
        int res = 0;
        for (int col = 0; col < n; col++) {
            for (int row = 1; row < m; row++) {
                if (strs[row - 1].charAt(col) > strs[row].charAt(col)) {
                    res++;
                    break;
                }
            }
        }
        return res;
    }
}
